package kr.hkit.powerjava.chapter21;

public class Example {
	static int num[];

	public static void main(String[] args) {
		/*String str[] = { "안녕하세요", "Hello!" };

		try {
			System.out.println(str[0]);
			System.out.println(num.length);
			System.out.println(str[2]);
		} catch (Exception e) {
			System.out.println("예외 발생: " + e);
		} finally {
			System.out.println("try 실행");
		}
		*/
		
		/*Object obj[] = new Integer[2];

		try {
			obj[0] = new Integer(3);
			obj[1] = new Double(3.4);
		} catch (ArrayStoreException e) {
			System.out.println("더블노노");
		}

		for (Object o : obj) {
			System.out.println(o);
		}*/
		
		
		/*double data[] = {3.1, 2.4, 4.6}
		
		try{
			System.out.println(data[3]);
		} catch (ArrayIndexOutOfBoundsException e){
			System.out.println("예외발생: " + e);
		} catch (IndexOutOfBoundsException e) {
			System.out.println("예외발생: " + e);
		}catch (Exception e) {
			System.out.println("예외발생: " + e);
	} */
		
	/*	
		try {
			System.out.println(Class.forName("Java.lang.Obj"));
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		
		/*Object obj[];
		try {
			obj = new Object[-3];
		}catch(NegativeArraySizeException ex) {
			System.out.println(ex);
		}catch(Exception ex) {
			System.out.println(ex);
		}*/
		
		
		/*int value = 5;
		
		try {
			System.out.println(1);
			value = value / 0;
			System.out.println(2);
		}catch (ArithmeticException e) {
			System.out.println(3);
		}catch (IndexOutOfBoundsException e) {
			System.out.println(4);
		}catch (Exception e) {
			System.out.println(5);
		}
		
		System.out.println(6);*/
		
		/*try{
			int data [] = new int[-3];	
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println(1);
		} catch (ClassCastException e) {
			System.out.println(2);
		} catch (NegativeArraySizeException e) {
			System.out.println(3);
		} finally {
			System.out.println(4);
		}*/
		
	/*	
		Integer in = new Integer(5);
		Object obj = null;
		try {
			obj = in;
		} catch (ArrayIndexOutOfBoundsException e) {
			System.out.println(1);
		} catch (ClassCastException e){
			System.out.println(2);
		} catch (Exception e) {
			System.out.println(3);
		} finally {
			System.out.println(4);
		}
		System.out.println(5);*/
		
		
		Object obj = new Object();
		try{
		Integer in = (Integer) obj;
		}catch(ArrayIndexOutOfBoundsException e) {
			System.out.println(1);
		}catch(ClassCastException e) {
			System.out.println(2);
		}catch(Exception e) {
			System.out.println(3);
		} finally {
			System.out.println(4);
		}
		System.out.println(5);
	
	}
	
}

